home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok15.lha
/
Seafarers_Manual
/
Source
/
CalcWeight.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
922b
|
37 lines
MODULE CalcWeight; (* Calculate average weight *)
(* From the book "Modula-2 A Seafarer's Manual and Shipyard Guide" *)
(* Page 53 adapted "Amiga M2Modula-2" 04 Mar 1988 *)
FROM InOut IMPORT WriteString,
WriteLn,
ReadCard;
FROM RealInOut IMPORT ReadReal,
WriteReal;
VAR
NumPeople : CARDINAL;
TotalWeight,
AverageWeight : REAL;
BEGIN
WriteString ("Enter number of people: ");
ReadCard (NumPeople); (* get group size from keyboard *)
IF (NumPeople # 0) THEN (* avoid division by 0 *)
WriteLn;
WriteString ("Total Weight? ");
ReadReal (TotalWeight);
AverageWeight := TotalWeight / FLOAT(NumPeople);
WriteLn;
WriteString ("Average weight is ");
WriteReal (AverageWeight,10,2);
WriteLn;
ELSE
WriteString ("Number must be > 0 to calculate average");
END;
END CalcWeight.